package com.qcby.demo.spi.iterable;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @className: IterableTest
 * @description:
 * @author: lxt
 * @create: 2021-05-20 18:46
 **/
public class IterableTest {

    public static void main(String[] args) {
        // 创建集合
        ArrayList<String> sites = new ArrayList<String>();
        sites.add("Google");
        sites.add("Runoob");
        sites.add("Taobao");
        sites.add("Zhihu");

        // 获取迭代器
        Iterator<String> it = sites.iterator();
        // 输出集合中的第一个元素
        System.out.println(it.next());
        System.out.println("===========Iterator=============");
        while(it.hasNext()){
            System.out.println(it.next());
        }
        System.out.println("===========for=============");
        for (String site : sites) {
            System.out.println(site);
        }
    }
}
